123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666 |
- <template>
- <div>
- <!-- 页面头部 -->
- <HomePageHead></HomePageHead>
- <HomePageNavigation1></HomePageNavigation1>
- <!-- 商圈详情 -->
- <div class="topicInfoBox">
- <div class="inner">
- <!-- 详情头部 -->
- <div class="infoHead">
- <div class="left">
- <div class="userInfo left">
- <el-badge value="楼主" class="item" type="warning">
- <img v-if='dataInfo.avatar' :src="dataInfo.avatar" alt="">
- <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png' alt="">
- </el-badge>
- <span>{{ dataInfo.author }}</span>
- </div>
- <div class="headContent left">
- <h2>{{ dataInfo.title }}</h2>
- <p v-show="dataInfo.group_name">
- 群聊:
- <span>{{ dataInfo.group_name }}</span>
- <button @click="joinGroup">加入群聊</button>
- </p>
- </div>
- </div>
- <div class="right">
- <div class="one">
- <span v-for="item in typeList" :key="index">
- <span v-if="dataInfo.type == item.value" class="one">{{item.label}}</span>
- </span>
- </div>
- <p>{{ dataInfo.updated_at }}</p>
- </div>
- </div>
- <!-- 详情页 文本+图片 -->
- <div class="infoContent" v-show="dataInfo.content">
- <div v-html="dataInfo.content"></div>
- </div>
- <div class="infoContent1" v-show="!dataInfo.content">
- <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Document_empty.png" alt="">
- <span>可以看看大家的互动哦~</span>
- </div>
- <!-- 详情页评论 -->
- <div class="comment">
- <h3>评论</h3>
- <div class="commentList" v-for="item in replyList" v-show="page_total != 0">
- <div class="left">
- <img v-if='item.avatar' :src="item.avatar" alt="" >
- <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png' alt="">
- <span class="name">{{ item.author }} : </span>
-
- </div>
- <div class="center">
- <span class="context">{{ item.content }}</span>
- </div>
- <div class="right">
- <span class="time">{{ item.created_at }}</span>
- <!-- <span>回复</span> -->
- </div>
- </div>
- <div class="comment_empty" v-show="page_total == 0">
- <img src="../../public/topic/message_empty.png" alt="">
- <span>暂无评论</span>
- </div>
- </div>
- <!-- 分页 -->
- <div class="paginationBox" v-show="page_total != 0">
- <el-pagination background layout="prev, pager, next" :total="page_total" prev-text="上一页"
- next-text="下一页" :default-page-size="pageSize" @change="changePage" />
- </div>
- </div>
- </div>
- <div class="message">
- <div class="inner">
- <input v-model="content" placeholder="快来回复吧~" type="text" class="messageInput">
- <button class="btn" @click="addReply">确定</button>
- </div>
- </div>
- <!-- 页面底部 -->
- <HomeFoot1></HomeFoot1>
- </div>
- </template>
- <script setup>
- //1.引用模块 start ---------------------------------------->
- //使用ref和reactive动态变量
- import { ref, reactive, onMounted } from 'vue'
- import { useRoute } from 'vue-router';
- //使用官方ssr请求模块
- import { useNuxtApp, useFetch } from '#app'
- //使用element-plus组件
- import { ElPagination, ElBadge, ElInput, ElMessage, ElMessageBox } from 'element-plus';
- // axios请求
- const nuxtApp = useNuxtApp();
- const axios = nuxtApp.$axios;
- const { $webUrl, $CwebUrl, $BwebUrl } = useNuxtApp()
- //1.引用模块 end ---------------------------------------->
- // 定义响应式数据
- const seoData = ref({
- title: '商圈',
- description: '默认描述',
- keywords: '默认关键词',
- image: 'https://example.com/default-image.jpg'
- });
- // 在 onMounted 钩子中获取数据
- onMounted(()=>{
- seoData.value.title = '商圈';
- seoData.value.description = '默认描述';
- seoData.value.keywords = '默认关键词';
- })
- //2.页面数据 start ---------------------------------------->
- const dataInfo = ref({})
- const groupId = useState("groupId", () => '')
- const replyList = useState("replyList", () => []) //评论列表
- //分页
- const page = ref(1)
- const pageSize = ref(5)
- let page_total = ref(0)
- const content = ref('')
- //2.页面数据 end ---------------------------------------->
- //3.获取商圈详情 start ---------------------------------------->
- const route = useRoute();
- const id = route.params.id; // 获取传递的 id 参数
- //页码发生改变
- const changePage = (val) => {
- console.log(val);
- page.value = val
- getTopicReply()
- }
- // 商圈信息
- const getTopicInfo = () => {
- let data = new FormData()
- data.append('id', id)
- axios.post('chat/getTopicInfo', data).then(res => {
- console.log('商圈信息', res);
- dataInfo.value = res.data
- groupId.value = res.data.group_id
- console.log(groupId.value);
- })
- }
- // 回复商圈 列表
- const getTopicReply = () => {
- let data = new FormData()
- data.append('id', id)
- data.append('page', page.value)
- data.append('page_size', pageSize.value)
- axios.post('chat/getTopicReply', data).then(res => {
- console.log('回复商圈列表 ', res);
- replyList.value = res.data.data
- // page_total.value = res.data.total
- page_total.value = res.data.total
- console.log("replyList", replyList);
- })
- }
- //5.获取分类和状态 start ---------------------------------------->
- const listData = useState("listData", () => [])//商圈列表
- const typeList = useState("typeList", () => [])//商圈分类
- const topicType = () => {
- axios.post('/chat/topicType').then(response => {
- console.log(111222333)
- console.log(response.data);
- // console.log(1);
- typeList.value = response.data;
- })
- }
- const topicStatus = () => {
- axios.post('chat/topicStatus').then(response => {
- console.log(response);
- })
- }
- onMounted(() => {
- getTopicInfo(); //商圈信息
- getTopicReply(); //回复商圈列表
- topicType();
- topicStatus();
- })
- //加入群聊
- const joinGroup = () => {
- ElMessageBox.confirm(
- '加入群聊后,页面跳转至后台群聊页面',
- '是否加入群聊?',
- {
- confirmButtonText: '是',
- cancelButtonText: '否',
- center: true,
- }
- ).then(() => {
- console.log('groupId.value', groupId.value);
- let data = new FormData()
- data.append('group_id', groupId.value)
- axios.post('chat/joinGroup', data).then(res => {
- console.log('加入群聊 ', res);
- if (res.code == 0 && res.message !== '已加入群') {
- ElMessage.error(res.message)
- } else if (res.code == 0 && res.message == '已加入群') {
- ElMessage({
- message: res.message,
- type: 'success',
- })
- setTimeout(() => {
- window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
- //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
- }, 1000)
- } else if (res.code == 200) {
- ElMessage({
- message: '加入成功',
- type: 'success',
- })
- setTimeout(() => {
- window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
- //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
- }, 1000)
- }
- })
- }).catch(() => {
- ElMessage({
- type: 'error',
- message: '已取消',
- })
- })
- }
- // 回复商圈
- const addReply = () => {
- let data = new FormData()
- data.append('id', id)
- data.append('content', content.value)
- axios.post('chat/addReply', data).then(res => {
- console.log('回复商圈 ', res);
- if (res.code == 0) {
- ElMessage.error(res.message)
- getTopicReply();
- } else if (res.code == 200) {
- ElMessage({
- message: '回复成功',
- type: 'success',
- })
- content.value = ''
- getTopicReply();
- }
- })
- }
- //3.获取商圈详情 end ---------------------------------------->
- //seo
- useSeoMeta({
- title: "商圈" + "_" + "三农资讯网_全国政务信息一体化应用平台",
- meta: [
- { name: 'description', content: "三农资讯网以服务于党和国家各级职能部门三农政务资讯发布及政务公开信息公示为基点,为全国县级以上各级党政机关及其职能部门配置各自公开独立网络发布平台。主要频道有:三农政务资讯,农科资讯,农资购销,农产购销,农贸资讯,三农致富信息,农村文化生活,三农政策法规,三农之窗,三农调查,三农服务,三农知识,农民工,打假维权等。三农资讯网打造最具影响力的三农信息发布平台,并成为最具权威的三农资讯网。_三农资讯网-测试专用_全国政务信息一体化应用平台" , tagPriority: 10 },
- { name: 'keywords', content: "三农资讯,农业,三农,三农在线,农业新闻,三农资讯网_三农资讯网-测试专用_全国政务信息一体化应用平台" , tagPriority: 10 }
- ]
- });
- </script>
- <style lang="less" scoped>
- .topicInfoBox {
- .inner {
- width: 1200px;
- margin: 0 auto;
- //信息头部
- .infoHead {
- height: 200px;
- padding: 65px 0 60px 40px;
- border-bottom: 1px solid rgba(0, 0, 0, 0.10);
- box-sizing: border-box;
- >.left {
- .userInfo {
- margin-right: 90px;
- .item {
- margin-top: -5px;
- margin-right: -5px;
- :deep(.el-badge__content.is-fixed) {
- position: absolute;
- right: calc(1px + var(--el-badge-size) / 2);
- top: 0;
- transform: translateY(-31%) translateX(79%);
- z-index: var(--el-index-normal);
- }
- img {
- width: 66px;
- height: 66px;
- vertical-align: middle;
- border-radius: 50%;
- }
- }
- span {
- margin-left: 15px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 18px;
- color: #333333;
- }
- }
- .headContent {
- h2 {
- width: 750px;
- height: 56px;
- line-height: 28px;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- text-overflow: ellipsis;
- word-break: break-all;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: bold;
- font-size: 20px;
- color: #333333;
- margin-bottom: 26px;
- }
- >p {
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 16px;
- color: #333333;
- button {
- width: 86px;
- height: 32px;
- background-color: #028e21;
- color: #fff;
- border: none;
- margin-left: 100px;
- }
- }
- }
- }
- >.right {
- position: relative;
- div {
- position: absolute;
- right: 0;
- top: 0;
- width: 71px;
- height: 32px;
- line-height: 32px;
- text-align: center;
- background-color: #d9f0d6;
- margin-bottom: 29px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 16px;
- color: #33B023;
- }
- .one {
- color: #FFAA33;
- background-color: #fbebd5;
- }
- .two {
- color: #33B023;
- background-color: #d5ecd2;
- }
- .three {
- color: #666;
- background-color: #ebebeb;
- }
- p {
- width: 150px;
- text-align: right;
- position: absolute;
- top: 62px;
- right: 0;
- }
- }
- }
- // 有详情信息
- .infoContent {
- width:1196px;
- overflow: hidden;
- padding: 40px 46px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-size: 20px;
- line-height: 40px;
- box-sizing: border-box;
- div{
- word-wrap: break-word; /* 强制长单词或 URL 换行 */
- overflow-wrap: break-word; /* 现代推荐用法,等同于 word-wrap */
- white-space: pre-wrap; /* 保留空白字符并允许自动换行 */
- word-break: break-all; /* 强制在任意字符处换行 */
- }
- }
- .leftBottom::v-deep p{
- width:1200px;
- white-space: pre-wrap;
- }
- //没有详情信息
- .comment_empty,
- .infoContent1 {
- height: 300px;
- line-height: 260px;
- text-align: center;
- img {
- width: 78px;
- height: 78px;
- vertical-align: -25px;
- vertical-align: middle;
- margin-right: 20px;
- }
- span {
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: bold;
- font-size: 26px;
- color: #CCCCCC;
- }
- }
- //评论
- .comment {
- h3 {
- height: 100px;
- padding-top: 30px;
- box-sizing: border-box;
- border-bottom: 1px solid #E1E1E1;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 22px;
- color: #000000;
- }
- .commentList {
- // height: 112px;
- border: 1px solid #E1E1E1;
- background-color: #fafafa;
- margin-top: 20px;
- padding: 30px 30px;
- box-sizing: border-box;
- display: flex;
- align-items: flex-start;
- justify-content: space-between;
- .left {
- width:400px;
- margin-right: 40px;
- // overflow: hidden;
- display: flex;
- justify-content: space-between;
- img {
- // float: left;
- width: 52px;
- height: 52px;
- border-radius: 50%;
- vertical-align: middle;
- margin-right: 15px;
- }
- span{
- // float: left;
- height: 52px;
- line-height: 22px;
- padding-top: 10px;
- }
- .name {
- width: 100px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 16px;
- color: #333333;
- margin-right: 30px;
- width: 100px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- display: block;
- }
-
- }
- .center {
- .context {
- width: 700px;
- margin-right: 40px;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- text-overflow: ellipsis;
- word-break: break-all;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: bold;
- font-size: 16px;
- color: #333333;
- }
- }
- .right {
- .time {
- display: block;
- width: 200px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 16px;
- color: #999999;
- margin-right: 30px;
- }
- span {
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 16px;
- color: #333333;
- }
- }
- }
- // .comment_empty {
- // height: 200px;
- // line-height: 200px;
- // text-align: center;
- // img {
- // width: 78px;
- // height: 78px;
- // vertical-align: -25px;
- // margin-right: 20px;
- // }
- // span {
- // font-family: Microsoft YaHei, Microsoft YaHei;
- // font-weight: bold;
- // font-size: 26px;
- // color: #CCCCCC;
- // }
- // }
- }
- }
- }
- //评论回复
- .message {
- width: 1200px;
- margin: 0 auto;
- padding: 0px 25px;
- box-sizing: border-box;
- height: 145px;
- line-height: 145px;
- background-color: #ecf5ee;
- .inner {
- .messageInput {
- width: 1000px;
- height: 67px;
- outline: none;
- border: 1px solid #E1E1E1;
- background-color: #fafafa;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 18px;
- color: #666;
- padding: 0 20px;
- box-sizing: border-box;
- }
- .btn {
- width: 115px;
- height: 40px;
- border: none;
- background-color: #028e21;
- color: #fff;
- border-radius: 6px;
- margin-left: 36px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 16px;
- }
- }
- }
- //分页
- .paginationBox {
- display: flex;
- justify-content: center;
- margin-top: 60px;
- margin-bottom: 90px;
- // 鼠标移入后字体颜色
- :deep(.el-pagination:hover) {
- color: #139609;
- }
- :deep(.el-pagination.is-background .btn-next),
- :deep(.el-pagination.is-background .btn-prev) {
- width: 70px;
- height: 34px;
- margin: 0px 10px;
- border-radius: 4px;
- }
- :deep(.el-pagination.is-background .el-pager li) {
- margin: 0px 10px;
- width: 38px;
- height: 34px;
- border-radius: 4px;
- }
- :deep(.el-pagination.is-background .btn-next.is-active),
- :deep(.el-pagination.is-background .btn-prev.is-active),
- :deep(.el-pagination.is-background .el-pager li.is-active) {
- background-color: #028e21;
- color: #fff;
- }
- }
- </style>
|